package own.knight.controller;    

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import own.knight.service.IUserService;

@Controller
@RequestMapping(value="/user")
public class UserController {

	@Autowired
	private IUserService userServiceImpl;
	
	@RequestMapping(value="/get")
	@ResponseBody
	public String findUser(HttpServletRequest req,HttpServletResponse res) {
		return userServiceImpl.findUser(1).toString();
	}
	
	@RequestMapping(value="/all")
	public ModelAndView findAll(ModelAndView mv) {
		mv.setViewName("user");
		mv.addObject("users", userServiceImpl.findAll());
		return mv;
	}
}
